package com.sfpay.coreplatform.member.service.validate;

import com.sfpay.coreplatform.member.common.MemberResponseCode;
import com.sfpay.coreplatform.member.common.enums.MemberStatus;
import com.sfpay.coreplatform.member.service.exception.MemberServiceException;
import com.sfpay.coreplatform.member.valueobject.dto.Member;

/**
 * 
 * 
 * 类说明：业务中常用校验
 *  
 * 
 * <p>
 * 详细描述：
 *   
 * 
 * @author 313717
 *   
 * CreateDate: 2013-4-17
 */
public class BussineValidate
{
	/**
	 * 
	 *
	 * 方法说明：校验会员状态
	 *
	 * @param member
	 * @throws MemberServiceException
	 */
	public static <T extends Member> void checkMemberStatus(T member)	throws MemberServiceException
	{
		if(member == null)
		{
			throw new MemberServiceException(MemberResponseCode.MEMBER_NOT_EXIST,"member is not exist");
		}
		if(member.getStatus() == MemberStatus.CANCEL)
		{
			throw new MemberServiceException(MemberResponseCode.MEMBER_HAS_CANCEL,"member has cancel");
		}
	}
}
